package com.ddxz.flink.chars.map;

import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.util.Collector;

/**
 * class description
 *
 * @author 朱宗刚
 * @version 1.0.0
 * @date 2020/9/1
 */

public class DdxzSplitterMap implements FlatMapFunction<String, Tuple2<String, Integer>> {
    @Override
    public void flatMap(String s, Collector<Tuple2<String, Integer>> collector) throws Exception {
        for(char c : s.toCharArray()) {
//            if(Character.isLetterOrDigit(c)){
                collector.collect(new Tuple2<>(String.valueOf(c), 1));
//            }
        }

//        for(String word : s.split("\\b")) {
//            if(word.trim().isEmpty()){
//                continue;
//            }
//            collector.collect(new Tuple2<>(word.trim(), 1));
//        }
    }
}
